package com.coin900.coin.service.sop;

import com.coin900.coin.persist.sop.SopButtonVO;
import com.coin900.coin.persist.sop.SopRoleButtonVO;
import com.value.mybatis.IDaoRouter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author shui
 * @create 2018-01-05
 **/
@Service
public class SopRoleButtonService implements ISopRoleButtonService {

    @Override
    public List<SopRoleButtonVO> loadSopRoleButton(Map<String, Object> params) {
        return this.daoRouter.query("SopRoleButton.loadSopRoleButton", params);
    }

    @Override
    public void insertSopRoleButton(SopRoleButtonVO sopRoleButtonVO) {
        this.daoRouter.insert("SopRoleButton.insertSopRoleButton", sopRoleButtonVO);
    }

    @Override
    public void insertSopRoleButtonBatch(Long roleId,List<SopButtonVO> sopButtonList) {
        for (SopButtonVO sopButtonVO : sopButtonList) {
            SopRoleButtonVO sopRoleButtonVO = new SopRoleButtonVO();
            sopRoleButtonVO.setRoleId(roleId);
            sopRoleButtonVO.setButtonId(sopButtonVO.getId());
            this.daoRouter.insert("SopRoleButton.insertSopRoleButton", sopRoleButtonVO);
        }
    }

    @Override
    public void updateSopRoleButton(SopRoleButtonVO sopRoleButtonVO) {
        this.daoRouter.update("SopRoleButton.updateSopRoleButton", sopRoleButtonVO);
    }

    @Override
    public void deleteSopRoleButton(SopRoleButtonVO sopRoleButtonVO) {
        this.daoRouter.update("SopRoleButton.deleteSopRoleButton", sopRoleButtonVO);
    }

    @Autowired
    private IDaoRouter daoRouter;

}